2000W / 48V LLC Battery-Charger  V1.00
xmc_wdt.h
Go to the documentation of this file.
1 
51 #ifndef XMC_WDT_H
52 #define XMC_WDT_H
53 
54 /*********************************************************************************************************************
55  * HEADER FILES
56  ********************************************************************************************************************/
57 
58 #include "xmc_common.h"
59 #include "xmc_scu.h"
86 /*********************************************************************************************************************
87  * MACROS
88  ********************************************************************************************************************/
89 
90 #define XMC_WDT_MAGIC_WORD (0xABADCAFEU) /* Magic word to be written in Service Register (SRV),
91  to service or feed the watchdog. */
92 
93 /*********************************************************************************************************************
94  * ENUMS
95  ********************************************************************************************************************/
96 
100 typedef enum XMC_WDT_MODE
101 {
108 
112 typedef enum XMC_WDT_DEBUG_MODE
113 {
117 
118 /*********************************************************************************************************************
119  * DATA STRUCTURES
120  ********************************************************************************************************************/
121  /* Anonymous structure/union guard start */
122 #if defined(__CC_ARM)
123  #pragma push
124  #pragma anon_unions
125 #elif defined(__TASKING__)
126  #pragma warning 586
127 #endif
128 
132 typedef struct XMC_WDT_CONFIG
133 {
141  union
142  {
143  struct
144  {
145  uint32_t : 1;
146  uint32_t prewarn_mode : 1;
147  uint32_t : 2;
148  uint32_t run_in_debug_mode : 1;
149  uint32_t : 3;
150  uint32_t service_pulse_width : 8;
153  uint32_t : 16;
154  };
155  uint32_t wdt_ctr; /* Value of operation mode control register (CTR). It’s bit fields are represented by above
156  union members. */
157  };
159 /* Anonymous structure/union guard end */
160 #if defined(__CC_ARM)
161  #pragma pop
162 #elif defined(__TASKING__)
163  #pragma warning restore
164 #endif
165 /*********************************************************************************************************************
166  * API PROTOTYPES
167  ********************************************************************************************************************/
168 
169 #ifdef __cplusplus
170 extern "C" {
171 #endif
172 
201 void XMC_WDT_Enable(void);
202 
228 void XMC_WDT_Disable(void);
229 
247 void XMC_WDT_Init(const XMC_WDT_CONFIG_t *const config);
248 
268 __STATIC_INLINE void XMC_WDT_SetWindowBounds(uint32_t lower_bound, uint32_t upper_bound)
269 {
270  WDT->WLB = lower_bound;
271  WDT->WUB = upper_bound;
272 }
273 
287 {
288  WDT->CTR = (WDT->CTR & (uint32_t)~WDT_CTR_PRE_Msk) | (uint32_t)mode;
289 }
290 
303 __STATIC_INLINE void XMC_WDT_SetServicePulseWidth(uint8_t service_pulse_width)
304 {
305  WDT->CTR = (WDT->CTR & (uint32_t)~WDT_CTR_SPW_Msk) | ((uint32_t)service_pulse_width << WDT_CTR_SPW_Pos);
306 }
307 
322 {
323  WDT->CTR = (WDT->CTR & (uint32_t)~WDT_CTR_DSP_Msk) | (uint32_t)debug_mode;
324 }
325 
341 {
342  WDT->CTR |= (uint32_t)WDT_CTR_ENB_Msk;
343 }
344 
359 {
360  WDT->CTR &= (uint32_t)~WDT_CTR_ENB_Msk;
361 }
362 
379 {
380  return WDT->TIM;
381 }
382 
402 {
403  WDT->SRV = XMC_WDT_MAGIC_WORD;
404 }
405 
423 {
424  WDT->WDTCLR = WDT_WDTCLR_ALMC_Msk;
425 }
426 
427 #ifdef __cplusplus
428 }
429 #endif
430 
439 #endif /* XMC_WDT_H */
__STATIC_INLINE uint32_t XMC_WDT_GetCounter(void)
Definition: xmc_wdt.h:378
uint32_t run_in_debug_mode
Definition: xmc_wdt.h:148
__STATIC_INLINE void XMC_WDT_SetServicePulseWidth(uint8_t service_pulse_width)
Definition: xmc_wdt.h:303
void XMC_WDT_Enable(void)
Definition: xmc_wdt.c:59
__STATIC_INLINE void XMC_WDT_Stop(void)
Definition: xmc_wdt.h:358
struct XMC_WDT_CONFIG XMC_WDT_CONFIG_t
#define WDT
Definition: XMC1400.h:8817
uint32_t wdt_ctr
Definition: xmc_wdt.h:155
#define WDT_CTR_PRE_Pos
Definition: XMC1400.h:2001
#define WDT_CTR_DSP_Msk
Definition: XMC1400.h:2004
__STATIC_INLINE void XMC_WDT_Start(void)
Definition: xmc_wdt.h:340
#define WDT_CTR_SPW_Msk
Definition: XMC1400.h:2006
__STATIC_INLINE void XMC_WDT_ClearAlarm(void)
Definition: xmc_wdt.h:422
__STATIC_INLINE void XMC_WDT_Service(void)
Definition: xmc_wdt.h:401
uint32_t prewarn_mode
Definition: xmc_wdt.h:146
void XMC_WDT_Disable(void)
Definition: xmc_wdt.c:74
__STATIC_INLINE void XMC_WDT_SetWindowBounds(uint32_t lower_bound, uint32_t upper_bound)
Definition: xmc_wdt.h:268
uint32_t window_upper_bound
Definition: xmc_wdt.h:134
XMC_WDT_DEBUG_MODE
Definition: xmc_wdt.h:112
__STATIC_INLINE void XMC_WDT_SetDebugMode(const XMC_WDT_DEBUG_MODE_t debug_mode)
Definition: xmc_wdt.h:321
__STATIC_INLINE void XMC_WDT_SetMode(XMC_WDT_MODE_t mode)
Definition: xmc_wdt.h:286
enum XMC_WDT_MODE XMC_WDT_MODE_t
uint32_t service_pulse_width
Definition: xmc_wdt.h:150
#define WDT_CTR_PRE_Msk
Definition: XMC1400.h:2002
#define XMC_WDT_MAGIC_WORD
Definition: xmc_wdt.h:90
#define WDT_CTR_SPW_Pos
Definition: XMC1400.h:2005
#define WDT_CTR_ENB_Msk
Definition: XMC1400.h:2000
void XMC_WDT_Init(const XMC_WDT_CONFIG_t *const config)
Definition: xmc_wdt.c:88
#define WDT_WDTCLR_ALMC_Msk
Definition: XMC1400.h:2030
#define WDT_CTR_DSP_Pos
Definition: XMC1400.h:2003
enum XMC_WDT_DEBUG_MODE XMC_WDT_DEBUG_MODE_t
#define __STATIC_INLINE
Definition: cmsis_gcc.h:47
XMC_WDT_MODE
Definition: xmc_wdt.h:100
uint32_t window_lower_bound
Definition: xmc_wdt.h:138